﻿@using Models;
@model scoresetting
@{
    ViewBag.Title = "打分配置";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

<section>
    <div class="container">
        <div class="breadcrumb">
            <ul>
                <li>
                    <a href="/admin/account/index">
                        <span class="fa fa-home"></span>
                        <span>返回主菜单&nbsp;&gt;&nbsp;</span>
                    </a>
                </li>
                <li>
                    <a href="javascript:void(0);">
                        <span class="active-b">打分配置</span>
                    </a>
                </li>
            </ul>
        </div>
        <form method="post" action="/admin/home/scoresetting" class="formvalidator" autocomplete="off">
            <div class="wrap min-height-600">
                @Html.HiddenFor(o => o.id)
                <div class="form-group">
                    <label class="col-xs-2">专家打分占比：</label>
                    <div class="col-xs-2">
                        @Html.TextBoxFor(o => o.expertpercent, new { type = "text", placeholder = "专家打分占比", @class = "with-unit validate[required,min[0],max[100]]" })%
                    </div>
                    <div class="col-xs-3">
                        <p style="line-height:34px;">输入0~100之间的数值</p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-2"></label>
                    <div class="col-xs-6">
                        <label class="check-item">
                            <input type="checkbox" name="isexcludeminandmax" id="isexcludeminandmax" @(Model.isexcludeminandmax ? "checked" : "")><span class="quare"></span>
                            <span>专家打分去除最高分和最低分</span>
                        </label>
                    </div>
                </div>
            </div>
            <ul class="big-btn">
                <li>
                    <input type="button" class="button active" value="保存" onclick="saveSetting(this)">
                </li>
                <li>
                    <input type="button" class="button" value="取消" onclick="return location.href = window.history.go(-1);">
                </li>
            </ul>
        </form>
    </div>
</section>

<script>
    function saveSetting() {
        var id = $("#id").val();
        var expertpercent = $("#expertpercent").val();
        var isexcludeminandmax = $("#isexcludeminandmax").is(":checked");

        var data = {
            id: id,
            expertpercent: expertpercent,
            isexcludeminandmax: isexcludeminandmax
        };
        $.ajax({
            type: "POST",
            url: "/admin/home/scoresetting",
            data: JSON.stringify(data),
            contentType: "application/json",
            success: function (data) {
                if (data.status) {
                    elayer.alert('提示', data.data, function () {
                        window.location.href = "/admin/home/scoresetting";
                    });
                }
                else {
                    elayer.alert('提示', data.errmsg);
                }
            },
            error: function (e) {
                elayer.alert('错误', e.responseText);
            }
        });
    }

</script>